import { Injectable } from '@angular/core';
import { HttpService } from '../providers/HttpService';
import { map, mergeMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { FileService } from '../providers/FileService';
import { ValidationErrors } from '@angular/forms';
import * as constants from '../providers/Constants'
import { Helper } from '../providers/Helper';

@Injectable({
    providedIn: 'root'
})
export class LoanService {
    constructor(public http: HttpService, public fileService: FileService,private mHelper:Helper) {
    }

    // 获取合同列表
    getContractList(data) {
        return this.http.post(constants.ApiServeLogin.getContractList, data);
    }

    // 获取合同详情
    getContractDetails(data) {
        return this.http.post(constants.ApiServeLogin.getContractDetail, data);
    }
    // 	修改或完善用户信息
    modifyUserInfo(data) {
        return this.http.post(constants.ApiServeLogin.modifyUserInfo, data);
    }
    // 	 获取家庭关系表
    getFamilyList() {
        return this.http.post(constants.ApiServeLogin.getFamilyList, {});
    }

    // 获取流水列表
    getAccJnlList(data) {
        return this.http.post(constants.ApiServeLogin.getAccJnlList, data);
    } // 上传图片文件
    uploadFile(data) {
        return this.http.post(constants.ApiServeLogin.uploadFile, data);
    }
    payApply(data) {
        if (this.mHelper.isAndroid()) {
            data.terminalType="0"
        }else if (this.mHelper.isIos()) {
            data.terminalType="1"
        }else{
            data.terminalType="0" 
        }
        return this.http.post(constants.ApiServeLogin.payApply, data);
    }
    // 获取图片地址
    getImageUrl() {
        return this.http.getImageUrl();
    }

}
